package com.bw.doctor.service.impl;
/**
 * @Author：尚志豪
 * @Package：com.bw.doctor.service.impl
 * @Project：doudi-group2-shixun-02
 * @name：PharmacyHistoricalPrescriptionServiceImpl
 * @Date：2025/2/25 20:32
 */

import com.bw.doctor.domain.Restoratives;
import com.bw.doctor.domain.res.HistoricalPrescriptionRes;
import com.bw.doctor.mapper.PharmacyHistoricalPrescriptionMapper;
import com.bw.doctor.service.PharmacyHistoricalPrescriptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: doudi-group2-shixun-02
 * @description: 我的药房历史处方
 * @author: CuiFu Bo
 * @create: 2025-02-25 20:32
 **/
@Service
public class PharmacyHistoricalPrescriptionServiceImpl implements PharmacyHistoricalPrescriptionService
{
    @Autowired
    private PharmacyHistoricalPrescriptionMapper prescriptionMapper;
    /**
     * B端 我的药房 历史处方列表
     */
    @Override
    public List<HistoricalPrescriptionRes> listOfHistoricalPrescriptions(Long doctorId) {
        return prescriptionMapper.listOfHistoricalPrescriptions(doctorId);
    }
    /**
     * B端 我的药房 历史处方详情
     */
    @Override
    public HistoricalPrescriptionRes historicalPrescriptionDetails(Long id, Long doctorId) {
        HistoricalPrescriptionRes prescriptionRes = prescriptionMapper.historicalPrescriptionDetails(id,doctorId);
        System.out.println("prescriptionRes" + prescriptionRes);
        List<String> strings = new ArrayList<>();
        for (String s : prescriptionRes.getDrugNames().split(",")) {
            strings.add(s);
        }
        System.out.println("s" + strings);
        prescriptionRes.setDrugName(strings);
        System.out.println("完整的:===" + prescriptionRes);
        return prescriptionRes;
    }
}
